package com.juicygames.undoer.player.property;

import com.juicygames.framework.action.UpdateAction;
import com.juicygames.framework.gamepart.GameHandler;
import com.juicygames.framework.gamepart.GamePart;
import com.juicygames.framework.property.IntegerProperty;
import com.juicygames.framework.property.space.XVelocity;
import com.juicygames.framework.property.space.YVelocity;

public class Friction extends GameHandler<UpdateAction> {
	
	float frictionValue;

	public Friction(GamePart self, float friction) {
		super(self);
		frictionValue = friction;
		setActionClassHandled(UpdateAction.class);
		self.addHandler(this);
		self.groundHandler(this);
	}
	
	public void handle(UpdateAction update) {
		IntegerProperty xVel = self.getPart(XVelocity.class);
		IntegerProperty yVel = self.getPart(YVelocity.class);

		xVel.set((int)(xVel.get() * frictionValue));
		yVel.set((int)(yVel.get() * frictionValue));
		
	}

}
